<?php
/**
 * #Celebrate Shieh
 *             ,%%%%%%%%,
 *           ,%%/\%%%%/\%%
 *          ,%%%\c "" J/%%%
 * %.       %%%%/ o  o \%%%
 * `%%.     %%%%    _  |%%%
 *  `%%     `%%%%(__Y__)%%'
 *  //       ;%%%%`\-/%%%'
 * ((       /  `%%%%%%%'
 *  \\    .'          |
 *   \\  /       \  | |
 *    \\/         ) | |
 *     \         /_ | |__
 *     (___________))))))) 攻城湿
 *
 *        _       _
 * __   _(_)_   _(_) __ _ _ __
 * \ \ / / \ \ / / |/ _` |'_ \
 *  \ V /| |\ V /| | (_| | | | |
 *   \_/ |_| \_/ |_|\__,_|_| |_|
 */

namespace App\Validator;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;

class AdminValidator
{
    use Validators;

    /**
     * 邮箱验证码
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function EmailCodeValidator( $request )
    {
        return Validator::make($request->all(), [
            'email' => 'required|max:30|email',
        ], [
            'email.required' => $this->getErrorCode()::message(2100),
            'email.max'      => $this->getErrorCode()::message(2101),
            'email.email'    => $this->getErrorCode()::message(2102),
        ])->errors();
    }

    /**
     * 系统配置
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function ConfigStoreInfoValidator( $request )
    {
        return Validator::make($request->all(), [
            'code'   => "required_with:code|max:10",
            'box'    => "required_with:box|email|max:30",
            'url'    => 'required_with:url|url|max:60',
            'name'   => "required_with:name|max:80",
            'record' => 'max:100',
            'info'   => 'max:100',
        ], [
            'code.max'   => $this->getErrorCode()::message(2103),
            'box.email'  => $this->getErrorCode()::message(2102),
            'box.max'    => $this->getErrorCode()::message(2101),
            'url.url'    => $this->getErrorCode()::message(2104),
            'url.max'    => $this->getErrorCode()::message(2105),
            'name.max'   => $this->getErrorCode()::message(2106),
            'record.max' => $this->getErrorCode()::message(2107),
            'info.max'   => $this->getErrorCode()::message(2108),
        ])->errors();
    }

    /**
     * 系统配置
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function ConfigStoreTitleValidator( $request )
    {
        return Validator::make($request->all(), [
            'title' => "required_with:title|max:100",
            'word'  => 'required_with:word|max:200',
        ], [
            'title.max' => $this->getErrorCode()::message(2109),
            'word.max'  => $this->getErrorCode()::message(2110),
        ])->errors();
    }


    /**
     * 系统配置
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function ConfigStoreServerValidator( $request )
    {
        return Validator::make($request->all(), [
            'sender'   => 'required|email|max:30',
            'code'     => 'required_with:code|max:10',
            'server'   => "required|max:30",
            'port'     => "required|max:9999|regex:/^[0-9]*$/",
            'name'     => 'required|max:30',
            'username' => 'required|max:30',
            'password' => 'required|max:30|regex:/^[a-zA-Z0-9]+([A-Za-z0-9])*$/',
        ], [
            'sender.required'   => $this->getErrorCode()::message(2100),
            'sender.email'      => $this->getErrorCode()::message(2102),
            'sender.max'        => $this->getErrorCode()::message(2101),
            'code.max'          => $this->getErrorCode()::message(2103),
            'server.required'   => $this->getErrorCode()::message(2111),
            'server.max'        => $this->getErrorCode()::message(2112),
            'port.required'     => $this->getErrorCode()::message(2113),
            'port.max'          => $this->getErrorCode()::message(2114),
            'port.regex'        => $this->getErrorCode()::message(2115),
            'name.required'     => $this->getErrorCode()::message(2116),
            'name.max'          => $this->getErrorCode()::message(2117),
            'username.required' => $this->getErrorCode()::message(2118),
            'username.max'      => $this->getErrorCode()::message(2119),
            'password.required' => $this->getErrorCode()::message(2120),
            'password.max'      => $this->getErrorCode()::message(2122),
            'password.regex'    => $this->getErrorCode()::message(2121),
        ])->errors();
    }

    /**
     * 系统配置
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function ConfigStoreCompanyValidator( $request )
    {
        return Validator::make($request->all(), [
            'phone'   => 'required_with:phone|regex:/^1[34578][0-9]{9}$/',
            'company' => "max:50",
            'qq'      => 'max:30',
            'fixed'   => 'max:30',
            'fax'     => 'max:30',
        ], [
            'phone.regex' => $this->getErrorCode()::message(2123),
            'company.max' => $this->getErrorCode()::message(2124),
            'qq.max'      => $this->getErrorCode()::message(2125),
            'fixed.max'   => $this->getErrorCode()::message(2126),
            'fax.max'     => $this->getErrorCode()::message(2127),
        ])->errors();
    }

    /**
     * 系统配置
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function ConfigStoreSerValidator( $request )
    {
        return Validator::make($request->all(), [
            'sender'   => 'required|email|max:30',
            'code'     => 'required_with:code|max:10',
            'server'   => "required|max:30",
            'port'     => "required|max:9999|regex:/^[0-9]*$/",
            'name'     => 'required|max:30',
            'username' => 'required|max:30',
            'password' => 'required|max:30|regex:/^[a-zA-Z0-9]+([A-Za-z0-9])*$/',
        ], [
            'sender.required'   => $this->getErrorCode()::message(2100),
            'sender.email'      => $this->getErrorCode()::message(2102),
            'sender.max'        => $this->getErrorCode()::message(2101),
            'code.max'          => $this->getErrorCode()::message(2103),
            'server.required'   => $this->getErrorCode()::message(2111),
            'server.max'        => $this->getErrorCode()::message(2112),
            'port.required'     => $this->getErrorCode()::message(2113),
            'port.max'          => $this->getErrorCode()::message(2114),
            'port.regex'        => $this->getErrorCode()::message(2115),
            'name.required'     => $this->getErrorCode()::message(2116),
            'name.max'          => $this->getErrorCode()::message(2117),
            'username.required' => $this->getErrorCode()::message(2118),
            'username.max'      => $this->getErrorCode()::message(2119),
            'password.required' => $this->getErrorCode()::message(2120),
            'password.max'      => $this->getErrorCode()::message(2122),
            'password.regex'    => $this->getErrorCode()::message(2121),
        ])->errors();
    }

    /**
     * 文件上传格式
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function FormatUpdatePictureValidator( $request )
    {
        return Validator::make($request->all(), [
            'picture'      => "required_with:picture|regex:/^([a-zA-Z0-9]+,)*[a-zA-Z0-9]+$/",
            'picture_cate' => "required_with:picture_cate|lt:1024|regex:/^[0-9]+$/",
            'picture_size' => "required_with:picture_size|lt:1024|regex:/^[0-9]+$/",
        ], [
            'picture.regex'      => $this->getErrorCode()::message(2128),
            'picture_cate.lt'    => $this->getErrorCode()::message(2129),
            'picture_cate.regex' => $this->getErrorCode()::message(2130),
            'picture_size.lt'    => $this->getErrorCode()::message(2131),
            'picture_size.regex' => $this->getErrorCode()::message(2132),
        ])->errors();
    }

    /**
     * 文件上传格式
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function FormatUpdateFileValidator( $request )
    {
        return Validator::make($request->all(), [
            'file'      => "required_with:file|regex:/^([a-zA-Z-0-9]+,)*[a-zA-Z-0-9]+$/",
            'file_cate' => "required_with:file_cate|lt:1024|regex:/^[0-9]+$/",
            'file_size' => "required_with:file_size|lt:1024|regex:/^[0-9]+$/",
        ], [
            'file.regex'      => $this->getErrorCode()::message(2128),
            'file_cate.lt'    => $this->getErrorCode()::message(2129),
            'file_cate.regex' => $this->getErrorCode()::message(2130),
            'file_size.lt'    => $this->getErrorCode()::message(2131),
            'file_size.regex' => $this->getErrorCode()::message(2132),
        ])->errors();
    }


    /**
     * 文件上传格式
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function FormatUpdateTextValidator( $request )
    {
        return Validator::make($request->all(), [
            'text'      => "required_with:text|regex:/^([a-zA-Z0-9]+,)*[a-zA-Z0-9]+$/",
            'text_cate' => "required_with:text_cate|lt:1024|regex:/^[0-9]+$/",
            'text_size' => "required_with:text_size|lt:1024|regex:/^[0-9]+$/",
        ], [
            'text.regex'      => $this->getErrorCode()::message(2128),
            'text_cate.lt'    => $this->getErrorCode()::message(2129),
            'text_cate.regex' => $this->getErrorCode()::message(2130),
            'text_size.lt'    => $this->getErrorCode()::message(2131),
            'text_size.regex' => $this->getErrorCode()::message(2132),
        ])->errors();
    }

    /**
     * 个人设置
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function ModifyStoreRenameValidator( $request )
    {
        return Validator::make($request->all(), [
            'code'   => "required_with:code|max:10",
            'email'  => "required_with:email|email|max:30|unique:users,email," . $request->input('id') . ",id,is_show,1",
            'rename' => "max:7",
        ], [
            'rename.max'   => $this->getErrorCode()::message(2133),
            'code.max'     => $this->getErrorCode()::message(2103),
            'email.email'  => $this->getErrorCode()::message(2102),
            'email.max'    => $this->getErrorCode()::message(2101),
            'email.unique' => $this->getErrorCode()::message(1003),
        ])->errors();
    }

    /**
     * 个人设置
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function ModifyStorePasswordValidator( $request )
    {
        return Validator::make($request->all(), [
            'password' => "required|string|min:5|max:12|confirmed|regex:/^[a-zA-Z0-9]+([A-Za-z0-9])*$/",
        ], [
            'password.required'  => $this->getErrorCode()::message(2134),
            'password.string'    => $this->getErrorCode()::message(2135),
            'password.min'       => $this->getErrorCode()::message(2136),
            'password.max'       => $this->getErrorCode()::message(2137),
            'password.confirmed' => $this->getErrorCode()::message(2138),
            'password.regex'     => $this->getErrorCode()::message(2121),
        ])->errors();
    }

    /**
     * 权限新增
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function PermissionStoreValidator( $request )
    {
        return Validator::make($request->all(), [
            'parent_id'  => 'required|max:80',
            'name'       => 'required|max:30|unique:permissions',
            'sort_order' => 'required|max:99|regex:/^[0-9]*$/',
            'label'      => 'required|max:30|unique:permissions',
            'icon'       => 'required_with:icon|max:30',
        ], [
            'parent_id.required'  => $this->getErrorCode()::message(2139),
            'parent_id.max'       => $this->getErrorCode()::message(2140),
            'name.required'       => $this->getErrorCode()::message(2141),
            'name.max'            => $this->getErrorCode()::message(2142),
            'name.unique'         => $this->getErrorCode()::message(2143),
            'sort_order.required' => $this->getErrorCode()::message(2144),
            'sort_order.max'      => $this->getErrorCode()::message(2145),
            'sort_order.regex'    => $this->getErrorCode()::message(2146),
            'label.required'      => $this->getErrorCode()::message(2147),
            'label.max'           => $this->getErrorCode()::message(2148),
            'label.unique'        => $this->getErrorCode()::message(2149),
            'icon.max'            => $this->getErrorCode()::message(2150),
        ])->errors();
    }

    /**
     * 权限修改
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function PermissionUpdateValidator( $request )
    {
        return Validator::make($request->all(), [
            'parent_id'  => 'required|max:80',
            'name'       => "required|max:30|unique:permissions,name," . $request->input('id') . ",id",
            'sort_order' => 'required|max:99|regex:/^[0-9]*$/',
            'label'      => "required|max:30|unique:permissions,label," . $request->input('id') . ",id",
            'icon'       => "required_with:icon|max:30",
        ], [
            'parent_id.required'  => $this->getErrorCode()::message(2139),
            'parent_id.max'       => $this->getErrorCode()::message(2140),
            'name.required'       => $this->getErrorCode()::message(2141),
            'name.max'            => $this->getErrorCode()::message(2142),
            'name.unique'         => $this->getErrorCode()::message(2143),
            'sort_order.required' => $this->getErrorCode()::message(2144),
            'sort_order.max'      => $this->getErrorCode()::message(2145),
            'sort_order.regex'    => $this->getErrorCode()::message(2146),
            'label.required'      => $this->getErrorCode()::message(2147),
            'label.max'           => $this->getErrorCode()::message(2148),
            'label.unique'        => $this->getErrorCode()::message(2149),
            'icon.max'            => $this->getErrorCode()::message(2150),
        ])->errors();
    }

    /**
     * 角色新增
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function RoleStoreValidator( $request )
    {
        return Validator::make($request->all(), [
            'name' => 'required|max:20|unique:roles',
        ], [
            'name.required' => $this->getErrorCode()::message(2151),
            'name.max'      => $this->getErrorCode()::message(2152),
            'name.unique'   => $this->getErrorCode()::message(2153),
        ])->errors();
    }

    /**
     * 角色更新
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function RoleUpdateValidator( $request )
    {
        return Validator::make($request->all(), [
            'name' => "required|max:20|unique:roles,name," . $request->input('id') . ",id",
        ], [
            'name.required' => $this->getErrorCode()::message(2151),
            'name.max'      => $this->getErrorCode()::message(2152),
            'name.unique'   => $this->getErrorCode()::message(2153),
        ])->errors();
    }

    /**
     * 用户新增
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function UserStoreValidator( $request )
    {
        return Validator::make($request->all(), [
            'code'     => 'required|max:10',
            'name'     => 'required|regex:/^[a-zA-Z0-9]+([A-Za-z0-9])*$/|unique:users,name,1,is_show,is_show,2|min:4|max:10',
            'email'    => 'required|email|max:30|unique:users,email,1,is_show,is_show,2',
            'phone'    => 'required_with:phone|regex:/^1[34578][0-9]{9}$/|unique:users,phone,1,is_show,is_show,2',
            'password' => 'required_with:password|min:6|max:30|regex:/^[a-zA-Z0-9]+([A-Za-z0-9])*$/',

        ], [
            'code.required'     => $this->getErrorCode()::message(2155),
            'code.max'          => $this->getErrorCode()::message(2103),
            'name.required'     => $this->getErrorCode()::message(2118),
            'name.regex'        => $this->getErrorCode()::message(2154),
            'name.unique'       => $this->getErrorCode()::message(2156),
            'name.min'          => $this->getErrorCode()::message(2157),
            'name.max'          => $this->getErrorCode()::message(2119),
            'email.required'    => $this->getErrorCode()::message(2100),
            'email.email'       => $this->getErrorCode()::message(2102),
            'email.max'         => $this->getErrorCode()::message(2101),
            'email.unique'      => $this->getErrorCode()::message(1003),
            'phone.regex'       => $this->getErrorCode()::message(2123),
            'phone.unique'      => $this->getErrorCode()::message(2158),
            'password.required' => $this->getErrorCode()::message(2120),
            'password.min'      => $this->getErrorCode()::message(2159),
            'password.max'      => $this->getErrorCode()::message(2122),
            'password.regex'    => $this->getErrorCode()::message(2121),
        ])->errors();
    }


    /**
     * 用户修改
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function UserUpdateEmailValidator( $request )
    {
        return Validator::make($request->all(), [
            'code'     => "required_with:code|max:10",
            'email'    => "required|email|max:30|unique:users,email," . $request->input('id') . ",id,is_show,1",
            'phone'    => "required_with:phone|regex:/^1[34578][0-9]{9}$/|unique:users,phone," . $request->input('id') . ",id,is_show,1",
            'password' => 'required_with:password|min:6|max:30|regex:/^[a-zA-Z0-9]+([A-Za-z0-9])*$/',
        ], [
            'code.required'     => $this->getErrorCode()::message(2155),
            'code.max'          => $this->getErrorCode()::message(2103),
            'email.required'    => $this->getErrorCode()::message(2100),
            'email.email'       => $this->getErrorCode()::message(2102),
            'email.max'         => $this->getErrorCode()::message(2101),
            'email.unique'      => $this->getErrorCode()::message(1003),
            'phone.regex'       => $this->getErrorCode()::message(2123),
            'phone.unique'      => $this->getErrorCode()::message(2158),
            'password.required' => $this->getErrorCode()::message(2120),
            'password.min'      => $this->getErrorCode()::message(2159),
            'password.max'      => $this->getErrorCode()::message(2122),
            'password.regex'    => $this->getErrorCode()::message(2121),
        ])->errors();
    }

    /**
     * DNF计算器
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function CalculationValidator( $request )
    {
        return Validator::make($request->all(), [
            'buy'    => "required|max:9|regex:/^[0-9]*$/",
            'sale'   => "required|max:9|regex:/^[0-9]*$/",
            'number' => "required|max:9|regex:/^[0-9]*$/",
        ], [
            'buy.required'    => $this->getErrorCode()::message(2164),
            'buy.max'         => $this->getErrorCode()::message(2165),
            'buy.regex'       => $this->getErrorCode()::message(2166),
            'sale.required'   => $this->getErrorCode()::message(2167),
            'sale.max'        => $this->getErrorCode()::message(2168),
            'sale.regex'      => $this->getErrorCode()::message(2169),
            'number.required' => $this->getErrorCode()::message(2170),
            'number.max'      => $this->getErrorCode()::message(2171),
            'number.regex'    => $this->getErrorCode()::message(2172),
        ])->errors();
    }

    /**
     * 创建聊天房间
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function ChatRoomValidator( $request )
    {
        return Validator::make($request->all(), [
            'title' => 'required|max:15|unique:rooms',
        ], [
            'title.required' => $this->getErrorCode()::message(2173),
            'title.max'      => $this->getErrorCode()::message(2174),
            'title.unique'   => $this->getErrorCode()::message(2175),
        ])->errors();
    }

    /**
     * 删除聊天房间
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function ChatRoomDeleteValidator( $request )
    {
        return Validator::make($request->all(), [
            'title' => 'required|max:15',
        ], [
            'title.required' => $this->getErrorCode()::message(2173),
            'title.max'      => $this->getErrorCode()::message(2174),
        ])->errors();
    }

    /**
     * 发送邮件
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function EmailStoreValidator( $request )
    {
        return Validator::make($request->all(), [
            'name'    => 'required|email|max:30',
            'title'   => 'required|max:200',
            'content' => 'required',
        ], [
            'name.required'    => $this->getErrorCode()::message(2100),
            'name.email'       => $this->getErrorCode()::message(2102),
            'name.max'         => $this->getErrorCode()::message(2101),
            'title.required'   => $this->getErrorCode()::message(2176),
            'title.max'        => $this->getErrorCode()::message(2177),
            'content.required' => $this->getErrorCode()::message(2178),
        ])->errors();
    }

    /**
     * 添加日历事件
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function FullCalendarStoreValidator( $request )
    {
        return Validator::make($request->all(), [
            'title' => "required|max:20",
            'color' => "required|max:30",
            'start' => "required|date|max:20",
        ], [
            'title.required' => $this->getErrorCode()::message(2179),
            'title.max'      => $this->getErrorCode()::message(2180),
            'color.required' => $this->getErrorCode()::message(2181),
            'color.max'      => $this->getErrorCode()::message(2182),
            'start.required' => $this->getErrorCode()::message(2183),
            'start.date'     => $this->getErrorCode()::message(2184),
            'start.max'      => $this->getErrorCode()::message(2185),
        ])->errors();
    }

    /**
     * 修改日历事件
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function FullCalendarUpdateValidator( $request )
    {
        if ( $request->input('active') == 'edit' ) $data = $request->input('data');
        else $data = $request->all();
        return Validator::make($data, [
            'id'    => "required|max:50",
            'start' => "required|date|max:20",
            'title' => "required|max:20",
            'color' => "required|max:30",
        ], [
            'id.required'    => $this->getErrorCode()::message(2186),
            'id.max'         => $this->getErrorCode()::message(2187),
            'start.required' => $this->getErrorCode()::message(2183),
            'start.date'     => $this->getErrorCode()::message(2184),
            'start.max'      => $this->getErrorCode()::message(2185),
            'title.required' => $this->getErrorCode()::message(2179),
            'title.max'      => $this->getErrorCode()::message(2180),
            'color.required' => $this->getErrorCode()::message(2181),
            'color.max'      => $this->getErrorCode()::message(2182),
        ])->errors();
    }

    /**
     * 修改日历事件
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function FullCalendarUpdateAllDayValidator( $request )
    {
        return Validator::make($request->input('data'), [
            'allDay' => "required|max:2",
            'end'    => "required|date|max:30",
        ], [
            'allDay.required' => $this->getErrorCode()::message(2188),
            'allDay.max'      => $this->getErrorCode()::message(2189),
            'end.required'    => $this->getErrorCode()::message(2190),
            'end.date'        => $this->getErrorCode()::message(2191),
            'end.max'         => $this->getErrorCode()::message(2192),
        ])->errors();
    }

    /**
     * 邮箱验证码
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function UserEmailCodeValidator( $request )
    {
        return Validator::make($request->all(), [
            'email' => "required|max:30|unique:users,email,1,is_show,is_show,2",
        ], [
            'email.required' => $this->getErrorCode()::message(2100),
            'email.max'      => $this->getErrorCode()::message(2101),
            'email.email'    => $this->getErrorCode()::message(2102),
            'email.unique'   => $this->getErrorCode()::message(1003),
        ])->errors();
    }

    /**
     * 邮箱验证码
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function UserEmailCodeUpdateValidator( $request )
    {
        return Validator::make($request->all(), [
            'email' => "required|max:30|unique:users,email," . $request->input('uid') . ",id,is_show,2",
        ], [
            'email.required' => $this->getErrorCode()::message(2100),
            'email.max'      => $this->getErrorCode()::message(2101),
            'email.email'    => $this->getErrorCode()::message(2102),
            'email.unique'   => $this->getErrorCode()::message(1003),
        ])->errors();
    }

    /**
     * 博客用户新增
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function BlogUserStoreValidator( $request )
    {
        return Validator::make($request->all(), [
            'code'      => 'required|max:10',
            'name'      => 'required|regex:/^[a-zA-Z0-9]+([A-Za-z0-9])*$/|unique:users,name,1,is_show,is_show,2|min:4|max:10',
            'email'     => 'required|email|max:30|unique:users,email,1,is_show,is_show,2',
            'phone'     => 'required_with:phone|regex:/^1[34578][0-9]{9}$/|unique:users,phone,1,is_show,is_show,2',
            'password'  => 'required_with:password|min:6|max:30|regex:/^[a-zA-Z0-9]+([A-Za-z0-9])*$/',
            'rename'    => 'required_with:rename|max:7',
            'username'  => 'required_with:username|max:30',
            'user_code' => 'required_with:user_code|max:20',
        ], [
            'code.required'     => $this->getErrorCode()::message(2155),
            'code.max'          => $this->getErrorCode()::message(2103),
            'name.required'     => $this->getErrorCode()::message(2118),
            'name.regex'        => $this->getErrorCode()::message(2154),
            'name.unique'       => $this->getErrorCode()::message(2156),
            'name.min'          => $this->getErrorCode()::message(2157),
            'name.max'          => $this->getErrorCode()::message(2119),
            'email.required'    => $this->getErrorCode()::message(2100),
            'email.email'       => $this->getErrorCode()::message(2102),
            'email.max'         => $this->getErrorCode()::message(2101),
            'email.unique'      => $this->getErrorCode()::message(1003),
            'phone.regex'       => $this->getErrorCode()::message(2123),
            'phone.unique'      => $this->getErrorCode()::message(2158),
            'password.required' => $this->getErrorCode()::message(2120),
            'password.min'      => $this->getErrorCode()::message(2159),
            'password.max'      => $this->getErrorCode()::message(2122),
            'password.regex'    => $this->getErrorCode()::message(2121),
            'rename.max'        => $this->getErrorCode()::message(2133),
            'username.max'      => $this->getErrorCode()::message(2117),
            'user_code.max'     => $this->getErrorCode()::message(2194),
        ])->errors();
    }

    /**
     * 博客用户编辑
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function BlogUserUpdateValidator( $request )
    {
        return Validator::make($request->all(), [
            'code'     => 'required_with:code|max:10',
            'email'    => "required_with:email|email|max:30|unique:users,email," . $request->input('id') . ",id,is_show,2",
            'phone'    => "required_with:phone|regex:/^1[34578][0-9]{9}$/|unique:users,phone," . $request->input('id') . ",id,is_show,2",
            'password' => 'required_with:password|min:6|max:30|regex:/^[a-zA-Z0-9]+([A-Za-z0-9])*$/',
            'rename'   => 'required_with:rename|max:7',
            'username' => 'required_with:username|max:30',
        ], [
            'code.max'       => $this->getErrorCode()::message(2103),
            'email.email'    => $this->getErrorCode()::message(2102),
            'email.max'      => $this->getErrorCode()::message(2101),
            'email.unique'   => $this->getErrorCode()::message(1003),
            'phone.regex'    => $this->getErrorCode()::message(2123),
            'phone.unique'   => $this->getErrorCode()::message(2158),
            'password.min'   => $this->getErrorCode()::message(2159),
            'password.max'   => $this->getErrorCode()::message(2122),
            'password.regex' => $this->getErrorCode()::message(2121),
            'rename.max'     => $this->getErrorCode()::message(2133),
            'username.max'   => $this->getErrorCode()::message(2117),
        ])->errors();
    }

    /**
     * 博客分类新增
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function CategoryValidator( $request )
    {
        return Validator::make($request->all(), [
            'parent_id'  => 'required|max:80',
            'name'       => 'required|max:30',
            'sort_order' => 'required|max:99|regex:/^[0-9]*$/',
        ], [
            'parent_id.required'  => $this->getErrorCode()::message(2139),
            'parent_id.max'       => $this->getErrorCode()::message(2140),
            'name.required'       => $this->getErrorCode()::message(2198),
            'name.max'            => $this->getErrorCode()::message(2199),
            'sort_order.required' => $this->getErrorCode()::message(2144),
            'sort_order.max'      => $this->getErrorCode()::message(2145),
            'sort_order.regex'    => $this->getErrorCode()::message(2146),
        ])->errors();
    }

    /**
     * 菜单 新增
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function ListValidator( $request )
    {
        return Validator::make($request->all(), [
            'name'       => 'required|max:30|unique:lists,name',
            'sort_order' => 'required|max:99|regex:/^[0-9]*$/',
        ], [
            'name.required'       => $this->getErrorCode()::message(2116),
            'name.max'            => $this->getErrorCode()::message(2117),
            'name.unique'         => $this->getErrorCode()::message(2201),
            'sort_order.required' => $this->getErrorCode()::message(2144),
            'sort_order.max'      => $this->getErrorCode()::message(2145),
            'sort_order.regex'    => $this->getErrorCode()::message(2146),
        ])->errors();
    }

    /**
     * 菜单 修改
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function ListUpdateValidator( $request )
    {
        return Validator::make($request->all(), [
            'name'       => "required|max:30|unique:lists,name," . $request->input('id') . ",id",
            'sort_order' => 'required|max:99|regex:/^[0-9]*$/',
        ], [
            'name.required'       => $this->getErrorCode()::message(2116),
            'name.max'            => $this->getErrorCode()::message(2117),
            'name.unique'         => $this->getErrorCode()::message(2201),
            'sort_order.required' => $this->getErrorCode()::message(2144),
            'sort_order.max'      => $this->getErrorCode()::message(2145),
            'sort_order.regex'    => $this->getErrorCode()::message(2146),
        ])->errors();
    }

    /**
     * 标签 新增
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function LabelValidator( $request )
    {
        return Validator::make($request->all(), [
            'name' => 'required|max:30|unique:labels,name',
        ], [
            'name.required' => $this->getErrorCode()::message(2116),
            'name.max'      => $this->getErrorCode()::message(2117),
            'name.unique'   => $this->getErrorCode()::message(2201),
        ])->errors();
    }

    /**
     * 标签 修改
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function LabelUpdateValidator( $request )
    {
        return Validator::make($request->all(), [
            'name' => "required|max:30|unique:labels,name," . $request->input('id') . ",id",
        ], [
            'name.required' => $this->getErrorCode()::message(2116),
            'name.max'      => $this->getErrorCode()::message(2117),
            'name.unique'   => $this->getErrorCode()::message(2201),
        ])->errors();
    }

    /**
     * 友情链接 新增
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function LinkValidator( $request )
    {
        return Validator::make($request->all(), [
            'name' => 'required|max:30',
            'url'  => 'required_with:url|url',
        ], [
            'name.required' => $this->getErrorCode()::message(2116),
            'name.max'      => $this->getErrorCode()::message(2117),
            'url.url'       => $this->getErrorCode()::message(2202),
        ])->errors();
    }

    /**
     * 公告新增
     *
     * @param Request $request
     *
     * @return \Illuminate\Support\MessageBag
     */
    public function NoticeValidator( $request )
    {
        return Validator::make($request->all(), [
            'name' => 'required|max:30',
        ], [
            'name.required' => $this->getErrorCode()::message(2116),
            'name.max'      => $this->getErrorCode()::message(2117),
        ])->errors();
    }

}
